function opendetailfile_user(data) {
	data = eval('(' + data + ')');
	$('#body').html("");
	var addhtml = $("#detailfile").html();
	Mustache.parse(addhtml);
	result = {
		file_id: data['file_id'],
		file_filenumber: data['file_filenumber'],
		file_filername: data['file_filername'],
		file_phonenumber: data['file_phonenumber'],
		file_money: data['file_money'],
		file_detail: data['file_detail'],
		file_pic: data['file_pic'],
		file_data: JSON.stringify(data)
	};
	var html = Mustache.render(addhtml, result);
	$('#body').html(html);
	var str = "";
	$.ajax({
		type: "post",
		url: host + "department/lookdepartment",
		async: true,
		datatype: "json",
		data: {
			TOKEN: $.cookie('TOKEN'),
			USERID: $.cookie('USERID'),
		},
		success: function(ret) {
			ret = eval('(' + ret + ')');
			if(ret['status'] == 1) {
				for(var i = 0; i < (ret['arr']).length; i++) {
					str += "<option value=" + ret['arr'][i]['department_name'] + ">" + ret['arr'][i]['department_name'] + "</option>";
				}
				$("#department").html(str);
				$("#department").val(data['file_department']);
			} else {
				alert(ret['msg']);
			}

			$("#fileclass").val(data['file_fileclass']);
		}
	});
	$("#fileBC").barcode(data['file_filenumber'], "code128");
}

function lookuserfile() {
	var addhtml = $("#moreinfofile").html();;
	Mustache.parse(addhtml);
	var html = Mustache.render(addhtml);
	$('#body').html(html);
	$.ajax({
		type: "post",
		url: host + "File/lookuserfilelist",
		async: true,
		data: {
			TOKEN: $.cookie('TOKEN'),
			USERID: $.cookie('USERID'),
			file_usernumber: $.cookie('USERID')
		},
		success: function(ret) {
			ret = eval('(' + ret + ')');
			if(ret['status'] == 1) {
				for(var i = 0; i < (ret['arr']).length; i++) {
					var addhtml = $("#moreinfofilebody").html();;
					Mustache.parse(addhtml);
					var filestatus = "已登记";
					if(ret['arr'][i]['file_isback'] == 0) {
						if(ret['arr'][i]['file_issignature'] == 1) {
							filestatus = "已签批";
							if(ret['arr'][i]['file_isfinish'] == 1) {
								filestatus = "已领取";
							}
						}
					} else {
						if(ret['arr'][i]['file_isback'] == 2) {
							filestatus = "待审核";
						} else {
							filestatus = "已退回";
						}

					}
					var result = {
						file_pic: ret['arr'][i]['file_pic'],
						file_filenumber: ret['arr'][i]['file_filenumber'],
						file_filestatus: filestatus,
						file_data: JSON.stringify(ret['arr'][i])
					}
					var html = Mustache.render(addhtml, result);
					$('#moreinfofile_html').html($('#moreinfofile_html').html() + html);
				}
			} else {
				alert(ret['msg']);
			}
		}
	});
}

function updatathefile(file_id) {
	$.ajax({
		type: "post",
		url: host + "file/updatathefile",
		async: true,
		datatype: "json",
		data: {
			TOKEN: $.cookie('TOKEN'),
			USERID: $.cookie('USERID'),
			file_id: file_id,
			file_usernumber: $.cookie('USERID'),
			file_filenumber: $("#file_filenumber").val(),
			file_filername: $("#file_filername").val(),
			file_phonenumber: $("#file_phonenumber").val(),
			file_department: $("#department").val(),
			file_fileclass: $("#fileclass").val(),
			file_money: $("#file_money").val(),
			file_detail: $("#file_detail").val()
		},
		success: function(ret) {
			ret = eval('(' + ret + ')');
			if(ret['status'] == 1) {
				lookuserfile();
			} else {
				alert(ret['msg']);
			}
		}
	});
}